<?php
/**
* Change logs
* Sept 30, 2010 - immanuel192 - create this module
*/
    // Sept 30, 2010 - immanuel192 - create this module

    class countdownmodule {
        function name() { return "Count Down module"; }
        function description() { return "Show countdown on your page. You can fully configure countdown"; }
        function author() { return "immanuel192 - ABSoft.vn"; }

        function hasSources() { return true; }
        function hasContent() { return true; }
        function hasViews() { return true; }

        function supportsWorkflow() { return false; }

        function permissions($internal = "") {
            /* Sept 28, 2010: immanuel192  - permission details - begin
            - Configure: Add & Edit
            - Administrate: Configure & Delete
            Sept 28, 2010: immanuel192  - permission details - end */
            return array(
            'administrate'=>'Administrate'
            );
        }

        function show($view,$loc = null, $title = "") {
            global $db;

            $config = $db->selectObject('countdownmodule_config',"location_data='".serialize($loc)."'");
            if ($config == null) {
               // set default config 
               // skin size
               $config->width=100;
               $config->height=100;
               // size of flash control inside
               $config->control_width=100;
               $config->control_height=100;
               // flash var config
               $config->eventDate=time(); // current date
               $config->daysColor="#cccccc";
               $config->hoursColor="#fe2309";
               $config->minutesColor="#82ca9c";
               $config->secondsColor="#c69c6d";
               $config->skin_fileid=0;
               $config->url='';
            }
            
            if ($config->skin_fileid > 0)
            {
                $file = $db->selectObject('file', 'id='.$config->skin_fileid);
                $config->picpath = BASE_URL . "/". $file->directory.'/'.$file->filename;
            }
            $config->eventDate=date("Y-m-d",$config->eventDate);
            //$file = $db->selectObject('file', 'id='.$value->file_id);
            //$value->picpath = $file->directory.'/'.$file->filename;
            //$links[$key]=$value;
            
            $template = new template('countdownmodule',$view,$loc);
            $template->assign('config',$config);
            $template->register_permissions(array('administrate'),$loc);
            $template->output();
        }

        function deleteIn($loc) {
            return true; // nothing to delete here
        }

        function copyContent($oloc,$nloc) {
            return true; // nothing to copy here
        }

        // no search support
    }

?>
